// function mockNew() {
//   let O = new Object()
//   const FunctionConstructor = [].shift.call(arguments)
//   O.__proto__ = FunctionConstructor.prototype
//   const result = FunctionConstructor.apply(O, arguments)
//   return typeof result === 'object' ? result : O
// }

function mockNew1(constructor,...args){
  const newObj = Object.create(constructor.prototype)
  const res = constructor.apply(newObj, args)
  return (typeof res === 'object' || typeof res === 'function') ? res : newObj
}

function Player(name) {
  this.name = name
  return function(){}
}
const p1 = mockNew1(Player, 'lu-ke')
// const p1 = new Player('lu-ke')
console.log(p1)